package com.liuhengjia.langchain4japply.config;

import dev.langchain4j.web.search.searchapi.SearchApiWebSearchEngine;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 搜索配置类
 */
@Configuration
@ConfigurationProperties(prefix = "search")
@Data
public class SearchConfig {
    private String engine;
    private String apiKey;

    /**
     * 搜索 API 联网搜索引擎 Bean
     *
     * @return searchApiWebSearchEngine
     */
    @Bean
    public SearchApiWebSearchEngine searchApiWebSearchEngine() {
        return SearchApiWebSearchEngine.builder()
                .apiKey(apiKey)
                .engine(engine)
                .build();
    }
}